LEADTOOLS Barcode (Leadtools.Barcode assembly)

ReadBarcode(RasterImage,LeadRect,BarcodeSymbology[],IBarcodeReadOptions[]) Method

Show in webframe
Example 







A Leadtools.RasterImage object that contains the image data. Must not be null.
A Leadtools.LeadRect that specifies the region of interest area in the image where the barcode search and detection is performed. You can specify empty rectangle to indicate that the search must be performed on the whole image.
An array of BarcodeSymbology enumeration members that specifies the barcode symbologies (types) to search for.
An array of IBarcodeReadOptions that specifies the options to use. This can be null, where the current default options is used. Otherwise, the method will use the option that corresponds to the symbologies being read, if the array does not contain specific options for a symbologies being read, then the default version will be used.

For information about this method please see ReadBarcode(RasterImage,LogicalRectangle,BarcodeSymbology[],BarcodeReadOptions[]).

Syntax
'Declaration
 
Public Overloads Function ReadBarcode( _
   ByVal image As RasterImage, _
   ByVal searchBounds As LeadRect, _
   ByVal symbologies() As BarcodeSymbology, _
   ByVal options() As IBarcodeReadOptions _
) As BarcodeData
'Usage
 
Dim instance As BarcodeReader
Dim image As RasterImage
Dim searchBounds As LeadRect
Dim symbologies() As BarcodeSymbology
Dim options() As IBarcodeReadOptions
Dim value As BarcodeData
 
value = instance.ReadBarcode(image, searchBounds, symbologies, options)

            

            
 function Leadtools.Barcode.BarcodeReader.ReadBarcode(RasterImage,LeadRect,BarcodeSymbology[],IBarcodeReadOptions[])( 
   image ,
   searchBounds ,
   symbologies ,
   options 
)

Parameters

image
A Leadtools.RasterImage object that contains the image data. Must not be null.
searchBounds
A Leadtools.LeadRect that specifies the region of interest area in the image where the barcode search and detection is performed. You can specify empty rectangle to indicate that the search must be performed on the whole image.
symbologies
An array of BarcodeSymbology enumeration members that specifies the barcode symbologies (types) to search for.
options
An array of IBarcodeReadOptions that specifies the options to use. This can be null, where the current default options is used. Otherwise, the method will use the option that corresponds to the symbologies being read, if the array does not contain specific options for a symbologies being read, then the default version will be used.

Return Value

An instance of BarcodeData or one of its derived classes that contains the symbology, data, location and any rotation angle of the barcode found. If no barcodes can be found, then this method will return null.
Remarks

Note: In LEADTOOLS for .NET, the equivalent to Leadtools.LeadRect is Leadtools.Forms.LogicalRectangle, also the equivalent to IBarcodeReadOptions is BarcodeReadOptions.

Example
Copy Code  
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;

      
public async Task BarcodeReader_ReadBarcodeExample4()
{
   string imageFileName = @"Assets\Barcode1.tif";
   // Create a Barcode engine
   BarcodeEngine engine = new BarcodeEngine();

   // Get the Barcode reader instance
   BarcodeReader reader = engine.Reader;

   using(RasterCodecs codecs = new RasterCodecs())
   {
      StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(imageFileName);
      using(RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)))
      {
         // Rotate the image by 90, so default option of reading horizonal barcodes will not work
         Debug.WriteLine("Rotating the image by 90 degrees");
         RotateCommand rotate = new RotateCommand(90 * 100, RotateCommandFlags.Resize, RasterColorHelper.FromKnownColor(RasterKnownColor.White));
         rotate.Run(image);

         // In the US, UPC barcodes are used to identity products. So, create an array of UPC symbologies
         BarcodeSymbology[] upcSymbologies =
         {
            BarcodeSymbology.UPCA,
            BarcodeSymbology.UPCE
         };

         // Read the first UPC barcode from the image using default options
         Debug.WriteLine("Reading barcodes using default options");
         BarcodeData barcode = reader.ReadBarcode(image, LeadRectHelper.Empty, upcSymbologies, null);

         // Show its location and data if found
         // This will print out "Not found"
         if(barcode != null)
         {
            Debug.WriteLine("Found a {0} barcode at {1}, data:\n{2}", barcode.Symbology, barcode.Bounds, barcode.Value);
         }
         else
         {
            Debug.WriteLine("Not found");
         }

         // Now get the options we used previously, and change the 1D linear barcode read options
         // to search for barcodes in both horizontal and vertical directions
         // Note: Same options are used for UPCA and UPCE, so we only need one options class
         OneDBarcodeReadOptions oneDReadOptions = reader.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeReadOptions;

         // Change the read direction
         oneDReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical;

         // Try again using our options
         Debug.WriteLine("Reading barcodes using our options");
         barcode = reader.ReadBarcode(image, LeadRectHelper.Empty, upcSymbologies, new IBarcodeReadOptions[] { oneDReadOptions });

         // Show its location and data if found
         // This will find the barcode and print its information now
         if(barcode != null)
         {
            Debug.WriteLine("Found a {0} barcode at {1}, data:\n{2}", barcode.Symbology, barcode.Bounds, barcode.Value);
         }
         else
         {
            Debug.WriteLine("Not found");
         }
      }
   }
}
Requirements

Target Platforms

See Also

Reference

BarcodeReader Class
BarcodeReader Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Barcode requires a Barcode Module license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features